package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理模块")
public class NursingProjectController {

    @Resource
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation(value = "分页查询护理项目", notes = "根据页码、每页数量、名称和状态分页查询护理项目列表")

    public ResponseResult<NursingProject> selectByPage(
            @ApiParam(value = "页码", required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "每页数量", required = true) @RequestParam Integer pageSize,
            @ApiParam(value = "名称") @RequestParam(required = false) String name,
            @ApiParam(value = "状态") @RequestParam(required = false) Integer status) {

        PageResponse<NursingProjectVo> nursingProjectResponseResult = nursingProjectService.selectByPage(pageNum, pageSize, name, status);
        return ResponseResult.success(nursingProjectResponseResult);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID查询护理项目详情", notes = "通过护理项目的ID获取详细信息")

    public ResponseResult<NursingProjectVo> selectNursingProjectById(@PathVariable @ApiParam(value = "护理项目ID", required = true) Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.selectNursingProjectById(id);
        return ResponseResult.success(nursingProjectVo);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理项目", notes = "根据ID删除护理项目")

    public ResponseResult<NursingProjectVo> deleteNursingProjectById(@PathVariable @ApiParam(value = "护理项目ID", required = true) Long id) {
        nursingProjectService.deleteNursingProjectById(id);
        return ResponseResult.success();
    }

    @PostMapping
    @ApiOperation(value = "新增护理项目", notes = "创建一个新的护理项目")

    public ResponseResult<NursingProjectVo> addNursingProject(@RequestBody @ApiParam(value = "护理项目详细信息", required = true) NursingProjectDto nursingProject) {
        nursingProjectService.addNursingProject(nursingProject);
        return ResponseResult.success();
    }

    @PutMapping
    @ApiOperation(value = "更新护理项目", notes = "根据提供的护理项目详细信息更新现有护理项目")

    public ResponseResult<NursingProjectVo> updateNursingProject(@RequestBody @ApiParam(value = "护理项目详细信息", required = true) NursingProjectDto nursingProject) {
        nursingProjectService.updateNursingProject(nursingProject);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "设置护理项目状态", notes = "根据ID护理项目的状态")
    public ResponseResult<NursingProjectVo> setStatus(@PathVariable @ApiParam(value = "护理项目ID", required = true) Long id, @PathVariable @ApiParam(value = "护理项目修改目标状态", required = true) Integer status) {
        nursingProjectService.setStatus(id, status);
        return ResponseResult.success();
    }

    @GetMapping("/all")
    public ResponseResult<NursingProjectVo> selectNursingProjectAll() {

        return ResponseResult.success(nursingProjectService.selectNursingProjectAll());
    }




}
